package com.glsc.ngateway.common.base.repo.mysql.opmanage.report.basicsettings;

import com.glsc.ngateway.common.base.domain.mysql.opmanage.report.basicsettings.AssetInfo;
import com.glsc.ngateway.common.base.dto.opmanage.report.basicsettings.AssetInfoDto;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface AssetInfoRepo extends JpaRepository<AssetInfo, Long>, JpaSpecificationExecutor<AssetInfo>{
    @Query(value = "select new com.glsc.ngateway.common.base.dto.opmanage.report.basicsettings.AssetInfoDto(t.assetId,'('||t.sysId||')'||t.assetName as assetName,t.sysId,t.shortName) from AssetInfo t WHERE  t.positionFlag = 1 " +
            "   and t.orgId <> 13 and t.assetId not in (select m.assetId from AssetPoolList m where m.assetPoolId=:assetPoolId)")
    List<AssetInfoDto> queryAssetInfoNotInclued(@Param("assetPoolId") Long assetPoolId);

    @Query(value = "select new com.glsc.ngateway.common.base.dto.opmanage.report.basicsettings.AssetInfoDto(t.assetId,'('||t.sysId||')'||t.assetName as assetName,t.sysId,t.shortName) from AssetInfo t WHERE  t.positionFlag = 1 " +
            "   and t.orgId <> 13 and t.assetId in (select m.assetId from AssetPoolList m where m.assetPoolId=:assetPoolId)")
    List<AssetInfoDto> queryAssetInfoInclued(@Param("assetPoolId") Long assetPoolId);

    @Query(value = "select new com.glsc.ngateway.common.base.dto.opmanage.report.basicsettings.AssetInfoDto(t.assetId,'('||t.sysId||')'||t.assetName as assetName,t.sysId,t.shortName) from AssetInfo t WHERE  t.positionFlag = 1 " +
            "   and t.orgId <> 13 ")
    List<AssetInfoDto> queryAssetInfo();

    // 固收部账户
    @Query(value = "select new com.glsc.ngateway.common.base.dto.opmanage.report.basicsettings.AssetInfoDto(t.assetId,'('||t.sysId||')'||t.assetName as assetName,t.sysId,t.shortName) from AssetInfo t WHERE  t.positionFlag = 1 " +
            "   and t.orgId in (5,14) ")
    List<AssetInfoDto> queryGSAssetInfo();
}
